<?php
/**
* 单页控制器
*/
class SinglePageController extends PlatformController
{
	/**
	 * 显示单页
	 */
	public function indexAction()
	{
		$singlePage=Factory::M('SinglePageModel');
		$pageInfo=$singlePage->getPageInfo();
		// var_dump($pageInfo);die();
		$this->assign('pageInfo',$pageInfo);
		$this->display('index.html');
	}
	public function addAction()
	{
		$this->display('add.html');
	}
	public function dealAddAction()
	{
		$pageInfo['title']=$this->escapeData($_POST['title']);
		$pageInfo['content']=addslashes($_POST['content']);
		if(empty($pageInfo['title']) ||  empty($pageInfo['content']))
		{
			$this->jump('index.php?p=Back&c=SinglePage&a=add',':(信息不完整!');
		}
		$singlePage=Factory::M('SinglePageModel');
		$result=$singlePage->insertPage($pageInfo);
		if($result)
		{
			$this->jump('index.php?p=Back&c=SinglePage&a=index');
		}
		else
		{
			$this->jump('index.php?p=Back&c=SinglePage&a=add','未知错误,添加失败');
		}
	}
	public function editAction()
	{
		
	}
	public function dealEditAction()
	{
		
	}
	public function delAction()
	{
		
	}
}